//
//  NetworkClient.h
//  CarService
//
//  Created by Nimo.Yu on 15/1/30.
//  Copyright (c) 2015年 lexingsoft. All rights reserved.
//
#import <AFNetworking.h>
#import <Foundation/Foundation.h>

static NSString *LoginDidFailureNotification=@"LoginDidFailureNotification";
static NSString *tokenFailureNotification=@"tokenFailureNotification";

typedef NS_ENUM(NSUInteger,ZLFileType)
{
    ZLFileTypeJPG,
    ZLFileTypePNG,
    ZLFileTypeWAV,
    ZLFileTypeM4a
};

typedef enum : NSUInteger {
    UpdateFileNormalImage = 0,
    UpdateFileChatMessageImage = 1,
    UpdateFileOther = 2
} UpdateFileType;

//Rest URI
//字典值列表
#define STD_CHOICES_VALUE_LIST_URI @"/standardChoicesValue/list/"
//字典值信息
#define STD_CHOICES_VALUE_URI @"/standardChoicesValue/value/"
//所有字典值信息
#define STD_CHOICES_VALUES_URI @"/standardChoicesValue/values/"

@interface NetworkClient : NSObject

///通用POST方法(可以设置Header)
+ (void) postRequest:(NSString *) path
          parameters:(NSDictionary *)parameters
    headerParameters:(NSDictionary *)headerParameters
          needPrompt:(BOOL) needPrompt
             success:(void (^)(id dataObject))success
             failure:(void (^)(id resultDict))failure;
///通用POST方法
+ (void) postRequest:(NSString *) path
          parameters:(NSDictionary *)parameters
          NeedPrompt:(BOOL) needPrompt
             success:(void (^)(id dataObject))success
             failure:(void (^)(id resultDict))failure;

///通用GET方法
+ (void) getRequest:(NSString *) path
         parameters:(NSDictionary *)parameters
         NeedPrompt:(BOOL) needPrompt
            success:(void (^)(id dataObject))success
            failure:(void (^)(id dataObject))failure;

///通用PUT方法(可以设置Header)
+ (void) putRequest:(NSString *) path
         parameters:(NSDictionary *)parameters
   headerParameters:(NSDictionary *)headerParameters
         NeedPrompt:(BOOL) needPrompt
            success:(void (^)(id dataObject))success
            failure:(void (^)(id resultDict))failure;

///通用PUT方法
+ (void) putRequest:(NSString *) path
         parameters:(NSDictionary *)parameters
         NeedPrompt:(BOOL) needPrompt
            success:(void (^)(id dataObject))success
            failure:(void (^)(id resultDict))failure;

///通用DELETE方法
+ (void) deleteRequest:(NSString *) path
            parameters:(NSDictionary *)parameters
            NeedPrompt:(BOOL) needPrompt
               success:(void (^)(id dataObject))success
               failure:(void (^)(id resultDict))failure;
/**
 *  上传专用Post方法
 *
 *  @param path                待上传的文件路径
 *  @param parameters          上传参数Dictionary
 *  @param needPrompt          是否显示Prompt
 *  @param block               ForDatal回调Block
 *  @param uploadProgressBlock 进度回调Block
 *  @param success             上传完成回调Block
 *  @param failure             上传失败回调Block
 */
+ (void) postUploadRequest:(NSString *) path
                parameters:(NSDictionary *)parameters
                NeedPrompt:(BOOL) needPrompt
 constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
             progressBlock:(void (^)(long long  sentBytes, long long  needSendBytes)) uploadProgressBlock
                   success:(void (^)(id dataObject))success
                   failure:(void (^)(id dataObject))failure;

/**
 *  @brief 下载专用方法
 *
 *  @param path                 待下载的文件路径
 *  @param parameters           下载参数Dictionary
 *  @param savedPath            保存 在磁盘的位置
 *  @param success              下载成功回调
 *  @param failure              下载失败回调
 *  @param progress             实时下载进度回调
 */
+ (NSOperation *) downloadRequest:(NSString *) path
              parameters:(NSDictionary *)parameters
               savedPath:(NSString*)savedPath
         downloadSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
         downloadFailure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
                progress:(void (^)(float progress, NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))progress;

///获取服务器地址
+ (NSString *)getHostAddress;
@end
